<template>
  <view class="change-password">
    <view class="header">
      <!-- 返回按钮 -->
      <tn-button 
        backgroundColor="tn-bg-left" 
        style="color: black; position: absolute; left: 5%; top: 10%; width: 35px; height: 35px; font-size: 25px;" 
        :border="false" 
        @click="handleReturn"
      >
        <text class="tn-icon-left"></text>
      </tn-button>
      <view class="title">修改密码</view>
    </view>

    <!-- 输入框区域 -->
    <view class="input-area">
		<tn-input
		  v-model="oldPassword" 
		  placeholder="请输入旧密码" 
		  type="password" 
		  :clearable="true"
		></tn-input>
		<tn-input
		  v-model="newPassword" 
		  placeholder="请输入新密码" 
		  type="password" 
		  :clearable="true"
		></tn-input>
		<tn-input
		  v-model="confirmPassword" 
		  placeholder="确认新密码" 
		  type="password" 
		  :clearable="true"
		></tn-input>
    </view>

    <!-- 保存按钮 -->
    <tn-button 
      backgroundColor="tn-bg-primary" 
      class="save-btn"
      @click="savePassword"
    >
      保存密码
    </tn-button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      oldPassword: "",
      newPassword: "",
      confirmPassword: ""
    };
  },
  methods: {
    // 返回设置页面
    handleReturn() {
      uni.navigateBack({ delta: 1 });
    },
    // 保存密码
    savePassword() {
      if (this.newPassword !== this.confirmPassword) {
        uni.showToast({
          title: "新密码与确认密码不一致",
          icon: "none"
        });
        return;
      }

      // 发送修改密码请求（这里模拟保存密码）
      uni.showToast({
        title: "密码修改成功",
        icon: "success"
      });
    }
  }
};
</script>

<style scoped>
.change-password {
  padding: 20px;
  background: linear-gradient(135deg, #6d5dfc 0%, #788eff 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.header {
  position: relative;
  margin-top: 20px;
  padding-bottom: 30px;
  text-align: center;
  width: 100%;
}

.title {
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  margin-top: 10px;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.input-area {
  margin-top: 40px;
  width: 100%;
  max-width: 400px;
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background-color: #fff;
  transition: border-color 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.input:focus {
  border-color: #4d90fe;
  outline: none;
  box-shadow: 0 0 0 2px #4d90fe;
}

.save-btn {
  font-size: 18px;
  width: 100%;
  height: 45px;
  margin-top: 30px;
  border-radius: 5px;
  background: linear-gradient(135deg, #6d5dfc 0%, #788eff 100%);
  color: #fff;
  transition: background 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.save-btn:active {
  background: linear-gradient(135deg, #5a4ac6 0%, #667de0 100%);
}

tn-button {
  background-color: #007bff;
}
</style>